﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Chenxin.Lib.Utility;

public partial class WorkReport_WorkReportSend :PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string RecordId = Context.Request.Params["RecordId"];
            string RelationId = Context.Request.Params["RelationId"];

            if (!string.IsNullOrEmpty(RecordId))
            {
                //发件箱
                Chenxin.Lib.Hr.Entity.WorkReport_OutBox entOutBox = Chenxin.Lib.Hr.BLL.WorkReport_OutBox.GetModel(new Guid(RecordId));

                //权限判断
                if (entOutBox.SenderId != CurrentUserInfo.UserId)
                {

                    Context.Response.Redirect(string.Format("/errorpage.aspx?msg={0}", "没有编辑此工作报告的权限"));
                }
                entOutBox.Content = Server.UrlDecode(entOutBox.Content);
                hidOutBox.Value = Chenxin.Lib.Utility.JsonHelp.Convert2Json(entOutBox);

                //附件
                DataSet ds = Chenxin.Lib.Hr.BLL.Attachment.GetListByBelong(RecordId, 10);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    string localPath ="/service/Download.ashx?file=/" + ds.Tables[0].Rows[0]["Path"].ToString();
                    ltFile.Text = string.Format("<div><input id=\"chkFile\" name=\"chkFile\" type=\"checkbox\" value=\"{0}\" checked /><a href=\"{2}\">{1}</a></div>", ds.Tables[0].Rows[0]["RecordId"], ds.Tables[0].Rows[0]["FileName"], localPath);
                }
            }
            else if (!string.IsNullOrEmpty(RelationId))
            {
                //发件箱
                Chenxin.Lib.Hr.Entity.WorkReport_OutBox entOutBox = Chenxin.Lib.Hr.BLL.WorkReport_OutBox.GetModel(new Guid(RelationId));
                entOutBox.Content = Server.UrlDecode(entOutBox.Content);
                hidRelatedOutBox.Value = Chenxin.Lib.Utility.JsonHelp.Convert2Json(entOutBox);
            }
        }
        catch (Exception ex)
        {
            Context.Response.Redirect("/errorpage.aspx?msg=" + ex.Message);
        }
    }
}
